<template>
    <div>
        <el-container>
            <el-header>
                <!-- 头部 -->
                <el-menu
                    :default-active="activeIndex"
                    class="el-menu-demo"
                    mode="horizontal"
                    background-color="#545c64"
                    text-color="#fff"
                    active-text-color="#ffd04b"
                    router
                >
                    <el-menu-item index="/index">首页</el-menu-item>

                    <el-menu-item index="/shop">商品</el-menu-item>
                    <el-menu-item index="/buy">订单</el-menu-item>
                    <el-menu-item index="/good">会员</el-menu-item>
                    <el-menu-item index="/until">设置</el-menu-item>
                    <el-submenu index="6">
                        <template slot="title">{{admin}}</template>
                        <el-menu-item index="2-1">修改密码</el-menu-item>
                        <el-menu-item index="2-2" @click="exit">退出登录</el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-header>
            <router-view></router-view>
        </el-container>
    </div>
</template>

<script>
export default {
    data() {
        return {
            activeIndex:'',
            admin:localStorage.getItem('name')||''
        };
    },
    methods: {
        exit(){
            localStorage.removeItem('token')
            this.$router.push('/')
            this.$message('退出成功')
            
        }
    },
};
</script>

<style lang="scss">
.el-header{
    padding: 0;
    

}
</style>